package demo01;

public class java_08 {
	final static int TOTAL=10;
	static Thread[] threads = new Thread[TOTAL];
	static int[] result = new int[TOTAL];
	public static void main(String[] args) {
		for(int i=0;i<10;i++){
			int start = i * 10 + 1;
			int end = start + 9;
			threads[i] = new Thread(new Sumnumbers(start, end, result, i));
			threads[i].start();
		}
		for (int i = 0; i < TOTAL; i++) {
			try {
				threads[i].join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		int totalSum = 0;
		for (int i = 0; i < TOTAL; i++) {
			totalSum += result[i];
		}
		System.out.println(totalSum);
	}
}
